{% extends 'admin/layout.html.twig' %}

{% set menu = 'admin_user_manage' %}

{% set script_controller = 'user/list' %}

{% block main %}

  {{ web_macro.flash_messages() }}

  <form id="user-search-form" class="form-inline well well-sm" action="" method="get" novalidate>
    <div class="mbm">



      <select class="form-control" name="datePicker" id="datePicker">
        {{ select_options({longinDate:'admin.user.manage.form.time_option.login'|trans, registerDate: 'admin.user.manage.form.time_option.register'|trans}, app.request.get('datePicker') ,'admin.user.manage.form.time_option.default'|trans) }}
      </select>
      <div class="form-group ">
        <input class="form-control" type="text" id="startDate" name="startDate"
               value="{{ app.request.query.get('startDate') }}" placeholder="{{ 'admin.user.form.input_placeholder.startDate'|trans }}">
        -
        <input class="form-control" type="text" id="endDate" name="endDate"
               value="{{ app.request.query.get('endDate') }}" placeholder="{{ 'admin.user.form.input_placeholder.endDate'|trans }}">
      </div>
    </div>

    <div class="form-group">
      {% include 'org/org-tree-select.html.twig' with {orgCode: app.request.get('orgCode'), modal: 'list'} %}
    </div>

    <div class="form-group">

      <select class="form-control" name="roles">
        {{ select_options(dict('userRole')|array_merge(allRoles), app.request.query.get('roles'), 'admin.user.manage.form.role_option.default'|trans) }}
      </select>
    </div>

    <span class="divider"></span>
    <div class="form-group">
      <select id="keywordUserType" name="keywordUserType" class="form-control">
        {{ select_options(dict('userType'), app.request.query.get('keywordUserType'), 'admin.user.manage.form.user_type_option.default'|trans) }}
      </select>
    </div>

    <div class="form-group">
      <select id="keywordType" name="keywordType" class="form-control">
        {{ select_options(dict('userKeyWordType'), app.request.query.get('keywordType') ? app.request.query.get('keywordType') : 'nickname') }}
      </select>
    </div>

    <div class="form-group">
      <input type="text" id="keyword" name="keyword" class="form-control" value="{{ app.request.query.get('keyword') }}"
             placeholder="{{ 'admin.user.form.input_placeholder.keyword'|trans }}">
    </div>

    <button class="btn btn-primary">{{ 'admin.user.form.btn.search_submit_btn'|trans }}</button>

    {% if has_permission('admin_user_export') and is_plugin_installed('UserImporter') %}
      <a class="btn btn-primary mhs" id="user-export" data-toggle="modal" data-target="#modal"
         data-url="{{ path('admin_user_export') }}">{{ 'plugin.admin.user.manage.form.user_export_btn'|trans }}</a>
    {% endif %}

  </form>

  <table id="user-table" class="table table-striped table-hover" data-search-form="#user-search-form">
    <thead>
    <tr>
        {% if setting('magic.enable_org','0') %}
          <th><input type="checkbox"  data-role="batch-select"></th>
        {% endif %}
      <th>{{ 'user.fields.username_label'|trans }}</th>
        {% include 'org/parts/table-thead-tr.html.twig' %}
      <th>{{ 'admin.user.manage.fields.mobile_label'|trans }}</th>
      <th>Email</th>
      <th>{{ 'admin.user.fields.register_date_label'|trans }}</th>
      <th>{{ 'admin.user.manage.fields.recent_login_label'|trans }}</th>
      <th width="10%">{{ 'admin.user.fields.operation_label'|trans }}</th>
    </tr>
    </thead>
    <tbody>
    <p class="text-muted">
      <span class="mrl">{{ 'admin.user.manage.fields.user_total_num_label'|trans }}<strong class="inflow-num">{{ userCount }}</strong></span>
    </p>
    {% for user in users %}
        {% include 'admin/user/user-table-tr.html.twig' with {user:user,profile:profiles[user.id]} %}
    {% endfor %}
    </tbody>
  </table>

  {% include 'org/batch-update-org-btn.html.twig' with {module:'user', formId:'user-search-form'} %}

  {#{% include 'org/org-tree-select.html.twig' with {orgCode: app.request.get('orgCode'), modal: 'list'} %}#}
  {{ admin_macro.paginator(paginator) }}
{% endblock %}